//
//  SWAppearanceManager.swift
//  BaseDemo
//
//  Created by linhan on 16/2/18.
//  Copyright © 2016年 me. All rights reserved.
//

import Foundation
import UIKit

private let _manager = SWAppearanceManager()

class SWAppearanceManager: NSObject
{
    private var _setup:Bool = false
    class func sharedManager() -> SWAppearanceManager
    {
        return _manager
    }
    
    override init()
    {
        super.init()
        
    }
    
    //主题样式变换
    var themeStyle:SWThemeStyle = SWThemeStyle(){
        didSet{
            //SWNotificationCenter.postNotificationName(NotificationName.ThemeStyleChanged)
        }
    }
    
    class var themeStyle: SWThemeStyle{
        return SWAppearanceManager.sharedManager().themeStyle
    }
    
    func setup()
    {
        if !_setup
        {
            _setup = true
            navigationBarSetup()
            
            SVProgressHUD.setMinimumDismissTimeInterval(1.5)
            SVProgressHUD.setDefaultStyle(SVProgressHUDStyle.dark)
        }
    }
    
    private func navigationBarSetup()
    {
        UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(-1000, 0), for: UIBarMetrics.default)
        
        let chevronReplacement:UIImage? = UIImage(named: "global_btn_back")?.withRenderingMode(.alwaysOriginal)
        UINavigationBar.appearance().backIndicatorImage = chevronReplacement
        UINavigationBar.appearance().backIndicatorTransitionMaskImage = chevronReplacement
        UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName:UIColor(hex: 0x313433), NSFontAttributeName:UIFont.systemFont(ofSize:18)]
        
        UINavigationBar.appearance().shadowImage = UIImage()
        UINavigationBar.appearance().barTintColor = UIColor(hex: 0xf8e9eb)
        
    }
    
    func createBackButton() -> UIButton
    {
        let button:UIButton = UIButton(type:.system)
        button.setTitle("返回", for: .normal)
        button.sizeToFit()
        return button
    }
    
    
    
}


class SWThemeStyle:NSObject
{
    var warningTextFont:UIFont!
    var fontContent:UIFont!
    
    static let CameraRollCellHeight:CGFloat = 90
    static let SWKidEventCellHeight:CGFloat = 270
    static let BookCellHeight:CGFloat = 50
    static let OrderCellHeight:CGFloat = 200
    
    
    var majorTitleColor:UIColor = UIColor.darkGray
    let MajorVCBackgroundColor:UIColor = UIColor.white
    var tableViewSeparatorColor:UIColor = UIColor(hex: 0xe6e9ed, alpha: 1)
    
    var cellDisclosureIndicatorColor:UIColor = UIColor(hex: 0x545454, alpha: 1)
    var cellBackgroundColor1:UIColor = UIColor(hex: 0xf9f9f9, alpha: 1)
    var cellBackgroundColor2:UIColor = UIColor(hex: 0xffffff, alpha: 1)
    var settingCellBackgroundColor:UIColor = UIColor(hex: 0xffffff, alpha: 1)
    var settingCellTextColor:UIColor = UIColor(hex: 0x585858, alpha: 1)
    
    var sectionHeaderBackgroundColor:UIColor = UIColor(hex: 0xe7eaeb, alpha: 1)
    var sectionHeaderTitleColor:UIColor = UIColor(hex: 0x414246, alpha: 1)
    
    override init()
    {
        super.init()
        trace("SWThemeStyle Init")
        warningTextFont = fontOfSize(17)
        fontContent = fontOfSize(14)
    }
    
    func fontOfSize(_ fontSize:CGFloat) -> UIFont
    {
        return UIFont.systemFont(ofSize:fontSize)
        //return UIFont(name:"FZMWJW--GB1-0", size: fontSize) ?? UIFont.systemFont(ofSize:fontSize)
    }
    
    
    

}
